package com.example.find_module;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.lifecycle.Observer;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewbinding.ViewBinding;

import com.blankj.utilcode.util.ToastUtils;
import com.example.adapter_sdk.quick.BaseQuickAdapter;
import com.example.common.mvvm.view.BaseFragment;
import com.example.find_module.databinding.FragmentFindtabBinding;

import java.util.List;

public class FindTabFragment extends BaseFragment<FragmentFindtabBinding, FindTabViewModel> {

    private FindAdapter findAdapter;

    @Override
    public View bindLayout() {
        return v.getRoot();
    }

    @Override
    public ViewBinding initBinding() {
        FragmentFindtabBinding binding=FragmentFindtabBinding.inflate(inflater);
        return binding;
    }

    @Override
    public void initView() {
        findAdapter = new FindAdapter();
        findAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
            @Override
            public void onItemChildClick(RecyclerView.Adapter adapter, int id, int position) {

            }
        });
    }

    @Override
    public void initData() {
        vm.collectList.observe(this, new Observer<List<CollectEntity.DataBean.CollectData>>() {
            @Override
            public void onChanged(List<CollectEntity.DataBean.CollectData> collectData) {
                LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
                layoutManager.setOrientation(RecyclerView.VERTICAL);
                v.findCollectRecycler.setAdapter(findAdapter);
                v.findCollectRecycler.setLayoutManager(layoutManager);
                findAdapter.setNewInstance(collectData);
            }
        });
    }






    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        System.out.println("###onCreate");
    }

    @Override
    public void onResume() {
        super.onResume();
        System.out.println("###onResume");
    }

    @Override
    public void onStart() {
        super.onStart();
        System.out.println("###onStart");
    }

    @Override
    public void onPause() {
        super.onPause();
        System.out.println("###onPause");
    }

    @Override
    public void onStop() {
        super.onStop();
        System.out.println("###onStop");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        System.out.println("###onDestroy");
    }


}
